// 大banner
$(function(){
	
		var as = $('.bannerBox .banner li').length;
		var spanNumA = 0;
		
		$('.bannerBox .banner').css('width',as*100+'%')
		$('.bannerBox .banner li').css('width',100/as+'%')
		function a(){
			$('.bannerBox .banner').css('left',-spanNumA*100+'%')
			$('.bannerBox .focus li').removeClass('ac')
			$('.bannerBox .focus li').eq(spanNumA).addClass('ac')
		}
		
		$('.bannerBox .focus li').click(function(){
			spanNumA = $(this).attr('index');
			a();
		})
		setInterval(function(){
			spanNumA++;
			if (as-1 < spanNumA) {
				spanNumA = 0;
			}
			a();					
		},5000)
});

//	广告banner
$(function(){
	
	var as = $('.advertisement_bannerBox .container .advertisement_banner li').length;
	var spanNumA = 0;
	
	$('.advertisement_bannerBox .container .advertisement_banner').css('width',as*100+'%')
	$('.advertisement_bannerBox .container .advertisement_banner li').css('width',100/as+'%')
	function a(spanNumA){
		$('.advertisement_bannerBox .container .advertisement_banner').css('left',-spanNumA*100+'%')
		$('.advertisement_bannerBox .container .advertisement_focus li').removeClass('ac')
		$('.advertisement_bannerBox .container .advertisement_focus li').eq(spanNumA).addClass('ac')
	}
	
	$('.advertisement_bannerBox .container .advertisement_focus li').click(function(){
		spanNumA = $(this).index();
		a(spanNumA);
	})
})

$(function(){
	$('.certification').parent().css('position','relative')	


		
	$('.top_left .top_left_search .search_type li').click(function(){
		$('.top_left .top_left_search .search_type li').removeClass('ac');
		$(this).addClass('ac');	
	})
})

//删除购物车
$(function(){
	var liNum = ""
		shopNum = 1,
		promptNum = 1,

	$('.shopping_cart .carttop').click(function(){
		if(shopNum==1){
			$('.shopping_cart .cartdown').css('display','block');
			shopNum = 2;
		}else{
			$('.shopping_cart .cartdown').css('display','none');
			shopNum = 1;
		}
	})

	$('body').click(function(){
		$('.shopping_cart .cartdown').css('display','none');
		shopNum = 1;
	})

	$(".shopping_cart").click(function(event){
	    event.stopPropagation();
	});
	$(".shopmask").click(function(event){
	    event.stopPropagation();
	});
	$(".shop_promptBox").click(function(event){
	    event.stopPropagation();
	});

	$('.shopping_cart .cartdown ul li .price span').click(function(){
		liNum = $(this).parent('.price').parent('a').parent('li').index()-1;
		$('.shop_promptBox').css('display','block');
		$('.shopmask').css('display','block');
	})

	$('.shop_promptBox span').eq(0).click(function(){
		$('.shop_promptBox').css('display','none');
		$('.shopmask').css('display','none');
	})
	$('.shop_promptBox span').eq(1).click(function(){
		$('.shop_promptBox').css('display','none');
		$('.shopmask').css('display','none');
	})

	//删除地址
	$('.distriBox ul li .abtn a:nth-child(3)').click(function(){
		$('.delete_promptBox').css('display','block');
		$('.shopmask').css('display','block');
		promptNum = 1
	})

	$('.BcardBox li .abtn a:nth-child(2)').click(function(){
		$('.delete_promptBox').css('display','block');
		$('.shopmask').css('display','block');
		promptNum = 2
	})

	$('.promptBox .delete_btn span').click(function(){
		var spanbtnNum = $(this).index();
		if(spanbtnNum!=0){
			$('.promptBox').css('display','none');
			$('.shopmask').css('display','none');
		}else{
			if(promptNum == 1){
				$('.delete_promptBox').css('display','none');
				$('.shopmask').css('display','none');
			}else{
				$('.delete_promptBox').css('display','none');
				$('.verifiBox').css('display','block');
			}
		}
	})

	$('.verifiBox .delete_btn span').eq(0).click(function(){
		$('.shopmask').css('display','none');
		$('.verifiBox').css('display','none');
	})

	$('.promptBox .head img').click(function(){
		$('.promptBox').css('display','none');
		$('.shopmask').css('display','none');
	})

})

//删除提示框
$(function(){
	var winHeight = $(window).height(),
		winwidth = $(window).width(),
		shopProboxH = $('.shop_promptBox').height(),
		shopProboxW = $('.shop_promptBox').width(),
		topNum = (winHeight-shopProboxH)/2,
		leftNum = (winwidth-shopProboxW)/2,
		ProboxH = $('.promptBox').height(),
		ProboxW = $('.promptBox').width(),
		topNumA = (winHeight-ProboxH)/2,
		leftNumA = (winwidth-ProboxW)/2;
		
	$('.shop_promptBox').css({
		'top':topNum+'px',
		'left':leftNum+'px',
	})
	$('.promptBox').css({
		'top':topNumA+'px',
		'left':leftNumA+'px',
	})
})

//获取验证码
$(function(){
	var clickNum = 0;
	$('#obtainNum').click(function(){
		if(clickNum == 0){
			var timeNum = 59;
			var obtainHtml = timeNum+"s后重新获取验证";
			$('#obtainNum').html(obtainHtml);
			$('#obtainNum').css('color','#bdbdbd');
			var sint = setInterval(function(){
				if(timeNum>1){
					timeNum--;
					obtainHtml = timeNum+"s后重新获取验证";
					$('#obtainNum').html(obtainHtml);
					clickNum = 1;
				}else if(timeNum==1){
					clearInterval(sint);
					$('#obtainNum').html('获取验证码');
					$('#obtainNum').css('color','#000');
					clickNum = 0;
				}
			},1000)
		}
	})
})